The present invention relates to the field of computer graphics, and in particular to methods and apparatus for creating, modifying, and using lights and other components to control the attributes and appearance of objects in computer graphics images. Many computer graphic images are created by mathematically modeling the interaction of light with a three dimensional scene from a given viewpoint. This process, called rendering, generates a two-dimensional image of the scene from the given viewpoint, and is analogous to taking a photograph of a real-world scene. Animated sequences can be created by rendering a sequence of images of a scene as the scene is gradually changed over time. A great deal of effort has been devoted to making realistic looking and artistically compelling rendered images and animations.
Lighting makes a substantial contribution to the visual appearance of objects in a scene. Some rendering applications attempt to simulate the physics of lights and their illumination effects on objects in a scene as realistically and accurately as possible. Other rendering applications allow lights and their illumination effects to deviate from real-world physics to provide a greater range of artistic expression.
Many rendering applications use shading programs, or shaders, to determine the visual characteristics of objects. The rendering application samples objects at many points to determine the values of pixels of the image. For each sample point on an object, one or more shaders are executed to determine the color, transparency, position, and/or other attributes. Shaders can evaluate numerous input parameters in determining their results. These input parameters include surface attributes of the object, such as the normal vector of the surface of the object at the sample point; material attributes of the object including color and transparency, for example derived from a texture map, and optical properties, such as diffuse and specular reflectivity coefficients; and illumination attributes, such as the color, intensity, direction, and shadowing of the sample point of the object from one or more light sources.
Many rendering applications allow light sources to “broadcast” any number of shader input parameters to one or more target objects in a scene. When shaders of a target object are executed to evaluate sample points, the shaders use these broadcast shader input parameters as well as shader input parameters of the object itself to determine the visual characteristics of the target objects sample points, and thus the visual characteristics of the objects as a whole.
One problem with this approach is that shader programs are typically tied to a surface or object in a scene. Thus, the illuminated value of the object is largely determined by the material shader programs. This limits artistic reflection, as most changes to the illumination must be made by modifying the shader programs of the object. Moreover, lights broadcast values to shaders associated with objects, but material shaders cannot communicate with lights. Thus, illumination computations are limited to effects in which light parameters are received and the material shader program then respond to these parameters. There is no way to perform illumination computations that modify light parameters in response to material shader programs.
Typically, a user using a lighting configuration application would have to access a large list of all possible parameters of the light. The user would then have to configure all of these parameters correctly to broadcast the appropriate shader input parameter values. This process is time-consuming, unwieldy, and error prone. In some implementations, special scripts and applications are required to parse the parameters of lights to generate supporting data and configuration parameters needed to correctly render lights.
Moreover, many parameters of a light may contradict each other if used incorrectly. For example, a previous lighting system could have 40 or more different parameters specifying the area of effect of a light source. These parameters, if used incorrectly, could interact in unpredictable ways. As a result of this complexity, users were required to have detailed knowledge of the lighting system and the functions of all of the light parameters to correctly configure lights.
Additionally, because the light sources are implemented using a monolithic structure, the shader code includes substantial amounts of parameter checking and special case handling routines for parsing all of the light parameters. These routines add substantial overhead, decreasing rendering performance.
Therefore, it is desirable to have a simpler, more efficient, more flexible, and less error-prone system and method for creating, configuring, modifying, customizing, rendering, and using lights in computer graphics images.